#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int a[4][22];
int ans[4];

int main() {
    memset(a, 0, sizeof(a));
    memset(ans, 0, sizeof(ans));
    int s[4];
    cin >> s[0] >> s[1] >> s[2] >> s[3];
    for(int i=0; i<4; i++)
        for(int j=0; j<s[i]; j++)
            cin >> a[i][j];
    for(int i=0; i<4; i++) {
        int t = 0;
        for(int j=0; j<s[i]; j++) {
            ans[i] += t > a[i][j] ? 0 : a[i][j] - t;
            t = abs(t - a[i][j]);
        }
    }
    cout << ans[0] + ans[1] + ans[2] + ans[3];
    return 0;
} 